package com.rams.jhms.fs;

import java.io.File;
import java.io.FileFilter;
import java.util.HashMap;
import java.util.Map;

public class MediaFileFilter implements FileFilter {
				//mask  name
	private Map<String, String> masks = new HashMap<String, String>();
	
	public MediaFileFilter() {
		super();
		
		initFilter();
	}

	private void initFilter() {
		masks.put("mp3", "MP3 Media File");
	}
	
	@Override
	public boolean accept(File file) {
		if (file.isDirectory())
			return false;
		
		String fileName = file.getName();
		
		int fileExtIndex = fileName.lastIndexOf('.');
		String fileExt = fileName.substring(fileExtIndex + 1);
		
		if (masks.get(fileExt) != null)
			return true;
		else
			return false;
	}
}
